package com.liujit.bms.app.controller;

import com.liujit.bms.app.domain.query.BlogMemberCollectionQuery;
import com.liujit.bms.app.domain.result.BlogMemberCollectionResult;
import com.liujit.bms.app.service.BlogMemberCollectionService;
import com.liujit.common.domain.params.BaseParams;
import com.liujit.common.domain.result.PageBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 博客会员收藏管理接口
 * @Author liujun
 * @Date 2021-07-16 18:15:42
 */
@RequiredArgsConstructor
@Api(tags = "博客会员收藏管理接口")
@RestController
@RequestMapping("/blog/member/collection")
public class BlogMemberCollectionController {

    private final BlogMemberCollectionService blogMemberCollectionService;

    @ApiOperation(value = "分页查询", notes = "根据博客会员收藏分页查询条件，分页查询博客会员收藏列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "query", value = "博客会员收藏分页查询条件", dataType = "BlogMemberCollectionQuery", dataTypeClass = BlogMemberCollectionQuery.class, paramType = "query") })
    @GetMapping("/getPage")
    public PageBean<BlogMemberCollectionResult> getPage(BlogMemberCollectionQuery query) {
        return blogMemberCollectionService.getPage(query);
    }

    @ApiOperation(value = "添加", notes = "根据博客会员收藏添加请求参数，添加博客会员收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "params", value = "博客会员收藏添加请求参数", dataType = "BaseParams", dataTypeClass = BaseParams.class, paramType = "body") })
    @PostMapping("add")
    public Boolean add(@RequestBody BaseParams params) {
        return blogMemberCollectionService.add(params);
    }

    @ApiOperation(value = "修改", notes = "根据博客会员收藏修改请求参数，修改博客会员收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "params", value = "博客会员收藏修改请求参数", dataType = "BaseParams", dataTypeClass = BaseParams.class, paramType = "body") })
    @PostMapping("/modify")
    public Boolean modify(@RequestBody BaseParams params) {
        return blogMemberCollectionService.modify(params);
    }

    @ApiOperation(value = "查询", notes = "根据文章id，查询是否收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "文章id", dataType = "Long", dataTypeClass = Long.class, paramType = "query") })
    @GetMapping("/get")
    public Integer get(Long id) {
        return blogMemberCollectionService.get(id);
    }

    @ApiOperation(value = "删除", notes = "根据博客会员收藏删除请求参数，删除博客会员收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "params", value = "博客会员收藏删除请求参数", dataType = "BaseParams", dataTypeClass = BaseParams.class, paramType = "body") })
    @PostMapping("/del")
    public Boolean del(@RequestBody BaseParams params) {
        return blogMemberCollectionService.del(params);
    }

    @ApiOperation(value = "清空", notes = "清空博客会员收藏")
    @PostMapping("/clear")
    public Boolean clear() {
        return blogMemberCollectionService.clear();
    }
}
